<?php

include APPPATH.'controllers/sys_gnc_mng.php';

class Log_keluar_masuk_kampus extends Sys_gnc_mng {

	protected $model_path = 'lkm_t_log_km';

	/*
	function index()
	{
		$data = array(
			'application' => get_application($this),
			'application_title' => $this->common->get_application_description(get_application($this)),
			'unit' => get_unit($this),
			'unit_title' => $this->common->get_unit_description(get_unit($this)),
			'unit_controller' => get_unit_controller($this),
			'page' => 'View Data',
			'navigation' => $this->_navigation(),
			'content' => "testing",
		);
		$this->load->view('layout/default', $data);		
	}

	function _navigation() {	
		$navigation = $this->load->view('lkm/nav/general', '', TRUE);
		return $navigation;
	}


	function form_keluar() {
		$content_data = array ("status"=>"out_campus","form_title"=>"Form Log Keluar");
		$data = array(
			'application' => get_application($this),
			'application_title' => $this->common->get_application_description(get_application($this)),
			'unit' => get_unit($this),
			'unit_title' => $this->common->get_unit_description(get_unit($this)),
			'unit_controller' => get_unit_controller($this),
			'page' => 'Form Keluar',
			'navigation' => $this->_navigation(),
			'content' => $this->load->view('lkm/form/log_keluar_entry', $content_data, TRUE),
		);
		//$this->load->view('bur/form/deferred_payment_request_entry', $content_data, TRUE);
		$this->load->view('layout/default', $data);
	}

	function form_masuk() {
		$content_data = array ("status"=>"in_campus","form_title"=>"Form Log Masuk");
		$data = array(
			'application' => get_application($this),
			'application_title' => $this->common->get_application_description(get_application($this)),
			'unit' => get_unit($this),
			'unit_title' => $this->common->get_unit_description(get_unit($this)),
			'unit_controller' => get_unit_controller($this),
			'page' => 'Form Masuk',
			'navigation' => $this->_navigation(),
			'content' => $this->load->view('lkm/form/log_keluar_entry', $content_data, TRUE),
		);
		//$this->load->view('bur/form/deferred_payment_request_entry', $content_data, TRUE);
		$this->load->view('layout/default', $data);
	}

	function submit_keluar() {
		$this->_processInsertLog();
		redirect("lkm/log_keluar_masuk_kampus/form_keluar");
	}

	function submit_masuk() {
		$this->_processInsertLog();
		redirect("lkm/log_keluar_masuk_kampus/form_masuk");
	}

	function _processInsertLog() {
		$nim = $this->input->post("nim");
		$status = $this->input->post("status");
		$dt_log = mdate("%Y-%m-%d %H:%i:%s");
		if ($this->_insertLog($nim, $dt_log, $status) ) {
			$this->common->flash_message("Log mahasiswa dengan NIM $nim sudah disimpan", -1);
		}else{
			$this->common->flash_message("Tidak ditemukan mahasiswa dengan NIM $nim", -1);
		}
	}

	function _insertLog($nim, $dt_log, $status) {
		//prepare data
		$data = array(
				"id"=>NULL,
				"key_aka_student"=>$nim,
				"dt_log"=>$dt_log,
				"key_lkm_status"=>$status
		);
		$this->db->from('aka_m_student');
		$this->db->where('key', $nim);
		$query = $this->db->get();
		if( $query->num_rows() > 0 ) {
			$this->db->insert("lkm_t_log_km",$data);
			return TRUE;
		}else return FALSE;
	}
	*/
}

?>